package com.fms.controller;

import com.fms.entity.WarehouseBoard;
import com.fms.entity.WarehouseHardware;
import com.fms.result.ResultData;
import com.fms.service.WarehouseBoardService;
import com.fms.service.WarehouseHardwareService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/warehouse")
@RequiredArgsConstructor
public class WarehouseController {
    private final WarehouseBoardService warehouseBoardService;

    private final WarehouseHardwareService warehouseHardwareService;

    //获取仓库板子信息
    @GetMapping("/getBoard")
    public ResultData getBoardByOrderId(){
        List<WarehouseBoard> boards = warehouseBoardService.getAllBoard();
        return ResultData.success("success",boards);
    }

    //获取订单出库板子信息
    @GetMapping("/getBoard/{orderId}")
    public ResultData getBoardByOrderId(@PathVariable("orderId") Long orderId){
        List<WarehouseBoard> boards = warehouseBoardService.getOutboundBoardByOrderId(orderId);
        return ResultData.success("success",boards);
    }

    //获取仓库五金信息
    @GetMapping("/getHardware")
    public ResultData getHardware(){
        List<WarehouseHardware> hardware = warehouseHardwareService.getAllHardware();
        return ResultData.success("success",hardware);
    }

    //获取订单出库五金信息
    @GetMapping("/getHardware/{orderId}")
    public ResultData getHardwareByOrderId(@PathVariable("orderId") Long orderId){
        List<WarehouseHardware> hardware = warehouseHardwareService.getOutboundHardwareByOrderId(orderId);
        return ResultData.success("success",hardware);
    }
}
